
import AbsMenu from '../absmenu.js'
import { useStore } from 'vuex';


class EditModeMenu extends AbsMenu.AbsMenu {
    constructor(map, item) {
        super(map, item);
    }

    act2Click(openFileFlag) {
        console.log("RunningModeMenu-----+" + this.menuSubItem);
        switch (this.menuSubItem) {
            case 'autocad':
                {
                    window.cmdInputDlg.editMode = "autocad";
                    this.switchWorkMode(this.menuSubItem);
                    if (!openFileFlag) {
                        this.setCanvasBackColor('rgba(0,0,0,1)');
                        this.setCanvasGrid(0);
                    }
                }
                break;

            case 'viso':
            case 'common':
                {
                    let toolbox = window.ToolCollapsePanel.value;
                    toolbox.profesionnalMode = false;
                    window.cmdInputDlg.editMode = "viso";
                    this.switchWorkMode('viso');
                    if (!openFileFlag) {
                        this.setCanvasBackColor('rgba(255,255,255,1)');
                        this.setCanvasGrid(0);
                    }
                }
                break;

            case 'xmind':
                {
                    window.cmdInputDlg.editMode = "xmind";
                    this.switchWorkMode(this.menuSubItem);
                    if (!openFileFlag) {
                        this.setCanvasBackColor('rgba(255,255,255,1)');
                        this.setCanvasGrid(0);
                    }

                }
                break;

            default:
                break;
        }
        this.map.rePaint(1);
    }

    switchWorkMode(mode) {
        console.log("switchWorkMode **********************");
        // const store = useStore();
        // store.commit("switchWorkMode", {map:this.map,mode});
        this.map.m_pConfigINTF.config("editMode", mode);
    }

    setCanvasBackColor(backColor) {
        let tINTF = this.map.m_pConfigINTF;
        tINTF.config("backcolor", backColor);
    }

    setCanvasGrid(flag) {
        const gridSpan = 20;
        const gridColor = 'rgba(128, 128, 128, 1)';
        let gridSetaInfo = { dis: flag, span: gridSpan, color: gridColor };
        this.map.m_pConfigINTF.config("grid", gridSetaInfo);
    }
}

export default { EditModeMenu }

